<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 1.引入 -->
    <script src="https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script>
</head>
<body>
    
</body>
<script>
    // window.onload = function() {
    //     var r = _.compact([0, 1, false, 2, '', 3]);

    //     console.log(r);
    // }

    function compact(arr){
        var newArr = []
        arr.forEach(function(item){
            if(!!item == true){
                newArr.push(item)
            }
        })
        return newArr;
    }

    var a = [1,0,'',false,2,3]

    var b = compact(a);

    console.log(b);

    function add(a,b){
        return a+b
    }

</script>
</html>